package com.lovo.zuoye;

import java.util.*;

public class Zuoye {
    public static void main(String[] args) {
        // 1、
        Scanner sc = new Scanner(System.in);
        Map<Integer,String> map = new HashMap<Integer, String>();
        map.put(1, "Amy");
        map.put(2, "Joe");
        map.put(3, "Tom");
        map.put(4, "Susan");
        Set set = map.keySet();
        for (Object obj : set){
            System.out.println(obj + ":" + map.get(obj));
        }
        System.out.println("请输入人名：");
        map.put(5,sc.next());
        map.remove(4);
        map.put(3,"Tommy");
        System.out.println("\n");
        Set set1 = map.keySet();
        for (Object obj1 : set1){
            System.out.println(obj1 + ":" + map.get(obj1));
        }
        //2、
        HashMap<Object,Integer> hashMap = new HashMap();
        String[] str = {"a", "b", "a", "b", "c", "a", "b", "c", "b"};
        int conut = 0;
        List list = Arrays.asList(str);
        Set set2 = new HashSet();
        set2.addAll(list);
        for (Object obj2 : set2){
            for (int j = 0; j < list.size(); j++){
                if (obj2.equals(list.get(j))){
                    conut++;
                }
            }
            hashMap.put(obj2,conut);
            conut = 0;
        }
        Set set3 = hashMap.keySet();
        for (Object obj3 : set3){
            System.out.println(obj3 + ":" + hashMap.get(obj3));
        }
    }
}
